/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package btracker;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

/**
 *
 * @author Sammy
 */
public class SetBudget {

    static JButton btnCancel;
    static JButton btnFinish;
    static JTextField txtBudget;
    static JTextField txtAlarm;
    static JLabel lblBudget;
    static JLabel lblAlert1;
    static JLabel lblAlert2;
    static JLabel lblEmpty;
    static JFrame frame;

    public static void setBudgetGUI() {

        
///////Declare new
        btnCancel = new JButton ("Cancel");
        btnFinish = new JButton ("Set Budget");
        txtBudget = new JTextField();
        txtBudget.setSize(50, 20);
        txtAlarm = new JTextField();
        txtAlarm.setSize(50, 20);
        lblEmpty = new JLabel ("           ");
        lblBudget = new JLabel("Budget ammount:   $");
        lblAlert1 = new JLabel("Alert me when I am:   $");
        lblAlert2 = new JLabel("Away from my budget amount");

        JPanel btnPanel = new JPanel();
        
        btnPanel.add(btnFinish);
        btnPanel.add(btnCancel);

        JPanel stage1 = new JPanel();
        stage1.setLayout(new GridLayout(0, 2, 1, 5));
        stage1.add(lblBudget);
        stage1.add(txtBudget);


        JPanel stage2 = new JPanel();
        stage2.setLayout(new GridLayout(0, 3, 10, 15));
        stage2.add(lblAlert1);
        stage2.add( txtAlarm);
        stage2.add( lblAlert2);

        //             Panel config        //
        JPanel lowerPanel = new JPanel();
        JPanel uperPanel = new JPanel();

        lowerPanel.add(btnPanel);
        uperPanel.setLayout(new GridLayout(3, 0, 15, 15));
        uperPanel.add(BorderLayout.LINE_START, lblEmpty);
        uperPanel.add(stage1);
        uperPanel.add(stage2);

        //                                 //
        
        /////// Button Config
        
        ButtonHandler onClick = new ButtonHandler();
        
        btnCancel.addActionListener(onClick);
        btnCancel.setActionCommand("cancel");
                
        btnFinish.addActionListener(onClick);
        btnFinish.setActionCommand("finish");


//          Frame config        //
        frame = new JFrame("Set User Budget");
        frame.setSize(555, 200);
        frame.setVisible(true);
        frame.setLocationRelativeTo(null);
        frame.add(BorderLayout.NORTH, uperPanel);
        frame.add(BorderLayout.SOUTH, lowerPanel);
//                           //


    }
    private static class ButtonHandler implements ActionListener {

        public void actionPerformed(ActionEvent e) {
            String command = e.getActionCommand();
            
            if (command.equals("finish")){
                
            }else if(command.equals("cancel")){
                frame.setVisible(false);
           
            
        }
 }
    }
}
